﻿using Microsoft.Xna.Framework;
using SomeGame.GUI.Widgets;
using SomeGame.GUI.Widgets.BlockWidgets;
using SomeGame.GUI.Widgets.Containers;
using SomeGame.GUI.Widgets.Events.Click;
using SomeGame.GUI.Widgets.InlineWidgets;

namespace SomeGame.GUI.Screens {

    public class MainMenuScreen : Screen, IClickSubscriber {

        public MainMenuScreen() {
            Name = ScreenManager.MAIN_MENU_SCREEN;
            RootContainer = new RootContainer(this, GameEngine.Blank, GameEngine.GameBounds, Color.Transparent);

            // Container.
            InlineContainer menuInlineContainer = new InlineContainer(GameEngine.Blank, new Color(10, 10, 10)) {
                ID = "MainMenuScreen_MenuInlineContainer",
                Margin = new Margin(100, 0, 0, 0),
                Padding = new Padding(10),
                HorizontalAlignment = HorizontalAlignment.Center
            };
            RootContainer.AddWidget(menuInlineContainer);

            // Play.
            Button playButton = new Button(GameEngine.Blank,
                200,
                50,
                new Color(150, 90, 50),
                GameEngine.Consolas16,
                Color.AntiqueWhite,
                "Play") {
                    ID = "MainMenuScreen_PlayButton",
                    HoverColor = new Color(170, 130, 80)
                };
            playButton.AddSubscriber(this);
            menuInlineContainer.AddWidget(playButton);
            menuInlineContainer.AddWidget(new Break());

            // Quit.
            Button quitButton = new Button(GameEngine.Blank,
                200,
                50,
                new Color(150, 90, 50),
                GameEngine.Consolas16,
                Color.AntiqueWhite,
                "Quit") {
                    Margin = new Margin(10, 0, 0, 0),
                    ID = "MainMenuScreen_QuitButton",
                    HoverColor = new Color(170, 130, 80)
                };
            quitButton.AddSubscriber(this);
            menuInlineContainer.AddWidget(quitButton);

            // Textbox.
			//menuInlineContainer.AddWidget(new Break());
			//Textbox textbox = new Textbox(GameEngine.Blank,
			//	200,
			//	30,
			//	Color.AntiqueWhite,
			//	GameEngine.Consolas16,
			//	Color.DarkOliveGreen) {
			//		Margin = new Margin(10, 0, 0, 0),
			//		Padding = new Padding(0, 0, 0, 5),
			//		MaxLength = 15
			//	};
			//menuInlineContainer.AddWidget(textbox);

            RootContainer.Layout();
        }

        public void OnClick(ClickEventArgs clickEventArgs) {
            switch (((Widget) clickEventArgs.ClickPublisher).ID) {
                case "MainMenuScreen_PlayButton":
                    ScreenManager.DeactivateScreen(ScreenManager.BACKGROUND_SCREEN);
                    ScreenManager.DeactivateScreen(Name);
                    ScreenManager.ActivateScreen(ScreenManager.PLAY_SCREEN);
                    break;
                case "MainMenuScreen_QuitButton":
                    ScreenManager.ActivateScreen(ScreenManager.ARE_YOU_SURE_SCREEN);
                    break;
            }
        }

    }

}